package s63.kong.shop.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import s63.kong.shop.modules.login.LoginService;
import s63.kong.shop.modules.login.LoginVo;
import s63.kong.shop.modules.token.Token;
import s63.kong.shop.pojo.AjaxResult;

@RestController
@Api(tags = "登录控制器")
public class LoginController {
    @Autowired
    private LoginService loginService;

    @ApiOperation(value = "普通用户登录",notes = "使用用户名,密码登录")
      @ApiResponses({
            @ApiResponse(code = 200,message = "成功",response = AjaxResult.class),
            @ApiResponse(code = 401,message = "失败",response = AjaxResult.class)
    })

    @PostMapping("/login")
    public AjaxResult login(@RequestBody LoginVo loginVo){
        Token token = loginService.login(loginVo);
        return AjaxResult.ok(token);
    }
}
